#include <iostream>
using namespace std;

template <typename T>
void BubbleSort(T *arr, int len);

int main(void)
{
    /* code */
    int arr[] = {9, 7, 2, 1, 6, 3, 4};
    int len = sizeof(arr)/sizeof(arr[0]);

    BubbleSort(arr, len);
    for (int i = 0; i < len; i++)
    {
        cout << arr[i] << " ";
    }

    return 0;
}

template <typename T>
void BubbleSort(T *arr, int len)
{
    for (int i = 0; i < len; i++)
    {
        int flag = 0;
        for (int j = 0; j < len - i; j++)
        {
            if(arr[j] > arr[j+1])
            {
                T temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
                flag = 1;
            }

        }
        if (flag == 0)
        {
            break;
        }
    
    }
    
}